<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateExaminationsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('examinations', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->comment('创建人，用户id');
            $table->string('name')->comment('考试名称');
            $table->unsignedBigInteger('subject_id')->comment('考试科目');
            $table->unsignedBigInteger('category_id')->comment('分类id');
            $table->tinyInteger('type')->default(1)->comment('试卷类型(1：正常试卷，2：练习试卷，3：闯关试卷，)');
            $table->dateTime('start_time')->comment('开考时间')->index();
            $table->dateTime('over_time')->comment('截至进场时间')->index();
            $table->integer('timer')->comment('考试时长');
            $table->string('peoples')->nullable()->comment('被考人id')->index();
            $table->string('reviewer')->comment('评卷人id');
            $table->unsignedBigInteger('test_list_id')->comment('试卷id');
            $table->tinyInteger('examination_mode')->default(0)->comment('考试模式(0：不需要指定人，1：需要指定人)');
            $table->integer('passing_mark')->default(60)->comment('及格分数，默认60');
            $table->tinyInteger('show_result')->default(0)->comment('允许查看成绩 0：不显示 1：显示 ');
            $table->tinyInteger('show_answer')->default(0)->comment('允许查看答案 0：不显示 1：显示 ');
            $table->tinyInteger('mouse_out')->default(0)->comment('鼠标移出自动交卷 0：不开启 1：开启 ');
            $table->integer('mouse_out_num')->default(0)->comment('鼠标移出次数');
            $table->tinyInteger('status')->default(0)->comment('考试的状态(0：未开始，1：进行中，2:已结束)')->index();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('examinations');
    }
}
